//package cn.stylefeng.guns.modular.api.controller;
//
//import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
//import cn.stylefeng.guns.modular.bms.model.params.BmsIndustryParam;
//import cn.stylefeng.guns.modular.bms.model.params.BmsPostInfoParam;
//import cn.stylefeng.guns.modular.bms.model.params.BmsWelfareParam;
//import cn.stylefeng.guns.modular.bms.model.result.BmsIndustryResult;
//import cn.stylefeng.guns.modular.bms.model.result.BmsPostInfoResult;
//import cn.stylefeng.guns.modular.bms.model.result.BmsWelfareResult;
//import cn.stylefeng.guns.modular.bms.service.BmsIndustryService;
//import cn.stylefeng.guns.modular.bms.service.BmsPostInfoService;
//import cn.stylefeng.guns.modular.bms.service.BmsWelfareService;
//import cn.stylefeng.guns.modular.wms.entity.Resume;
//import cn.stylefeng.guns.modular.wms.entity.WorkExp;
//import cn.stylefeng.guns.modular.wms.model.params.*;
//import cn.stylefeng.guns.modular.wms.model.result.*;
//import cn.stylefeng.guns.modular.wms.service.*;
//import cn.stylefeng.guns.utils.ImageUtil;
//import cn.stylefeng.guns.utils.MemberTokenUtil;
//import cn.stylefeng.guns.utils.json.ValidatorUtils;
//import cn.stylefeng.guns.utils.pdf.PdfUtils;
//import cn.stylefeng.guns.utils.word.ExportResumeUtil;
//import cn.stylefeng.guns.utils.word.ExportWordUtil;
//import cn.stylefeng.roses.core.base.controller.BaseController;
//import cn.stylefeng.roses.core.reqres.response.ResponseData;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.apache.poi.ss.util.ImageUtils;
//import org.hibernate.validator.constraints.pl.REGON;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
//import sun.misc.BASE64Encoder;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.ByteArrayOutputStream;
//import java.io.IOException;
//import java.io.InputStream;
//import java.net.HttpURLConnection;
//import java.net.URL;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//@Controller
//@RequestMapping("/api/wms")
//@Api(tags = "简历管理")
//@CrossOrigin
//public class ApiWmsController extends BaseController {
//
//    @Resource
//    private ResumeService resumeService;
//    @Resource
//    private JobExpectService jobExpectService;
//    @Resource
//    private ProExpService proExpService;
//    @Resource
//    private WorkExpService workExpService;
//    @Resource
//    private EduExpService eduExpService;
//    @Resource
//    private CollectService collectService;
//    @Resource
//    private ResumeFileService resumeFileService;
//
//    /**
//     * 查询简历列表
//     */
//    @ResponseBody
//    @RequestMapping(value = "/getResumeList", method = RequestMethod.GET)
//    @ApiOperation(value = "查询简历列表", notes = "查询简历列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "page", value = "页码", dataType = "Integer", paramType = "query"),
//            @ApiImplicitParam(name = "limit", value = "每页数量", dataType = "Integer", paramType = "query"),
//            @ApiImplicitParam(name = "companyId", value = "公司ID", required = false, paramType = "query")
//    })
//    public ResponseData getPositionList(ResumeParam param) {
//        LayuiPageInfo pageInfo = resumeService.findPageBySpec(param);
//        return ResponseData.success(pageInfo);
//    }
//
//    /**
//     * 查询简历基本信息
//     */
//    @ResponseBody
//    @RequestMapping(value = "/getResumeInfo", method = RequestMethod.GET)
//    @ApiOperation(value = "查询简历基本信息", notes = "查询行业信息列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header")
//    })
//    public ResponseData getResumeInfo() {
//        try {
//            //取得当前Token登录者会员的ID
//            int memberId = MemberTokenUtil.getMemberId();
//            ResumeParam param = new ResumeParam();
//            param.setMemberId(memberId);
//            ResumeResult resume = resumeService.findBySpec(param);
//            if (resume == null) {
//                return ResponseData.error("暂无基本信息");
//            }
//            return ResponseData.success(resume);
//        } catch (Exception e) {
//            return ResponseData.error(e.getMessage());
//        }
//    }
//
//    /**
//     * 查询简历信息
//     */
//    @ResponseBody
//    @RequestMapping(value = "/getResume", method = RequestMethod.GET)
//    @ApiOperation(value = "查询简历信息", notes = "查询简历信息")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header")
//    })
//    public ResponseData getResume(ResumeParam param) {
//        try {
//            //取得当前Token登录者会员的ID
//            int memberId = MemberTokenUtil.getMemberId();
//            CollectResult collectResult = null;
//            if (param.getId() == null) {
//                param.setMemberId(memberId);
//            } else {
//                //非本人查询
//                collectResult = collectService.findBySpec(new CollectParam().setResumeId(param.getId()).setComMemberId(memberId));
//            }
//            ResumeResult resume = resumeService.getResume(param);
//            //是否已读
//            if (collectResult != null) {
//                resume.setIfCollect(true);
//            }
//            return ResponseData.success(resume);
//        } catch (Exception e) {
//            System.err.println(e.getMessage());
//        }
//        return ResponseData.error("查询失败");
//    }
//
//    /**
//     * 更新简历基本信息
//     */
//    @ResponseBody
//    @RequestMapping(value = "/updateResumeBasic", method = RequestMethod.POST)
//    @ApiOperation(value = "查询简历基本信息", notes = "查询行业信息列表")
//    public ResponseData updateResumeBasic(@RequestBody ResumeParam resumeParam) {
//        //取得当前Token登录者会员的ID
//        int memberId = MemberTokenUtil.getMemberId();
//        resumeParam.setMemberId(memberId);
//        resumeService.update(resumeParam);
//        return ResponseData.success();
//    }
//
//    /**
//     * 添加/更新期望职位
//     */
//    @ResponseBody
//    @RequestMapping(value = "/updateJobExpect", method = RequestMethod.POST)
//    @ApiOperation(value = "更新期望职位", notes = "更新期望职位")
//    public ResponseData updateJobExpect(@RequestBody JobExpectParam jobExpectParam) {
//        //取得当前Token登录者会员的ID
//        int memberId = MemberTokenUtil.getMemberId();
//        jobExpectParam.setMemberId(memberId);
//        jobExpectService.update(jobExpectParam);
//        return ResponseData.success();
//    }
//
//    /**
//     * 查询期望职位列表
//     */
//    @ResponseBody
//    @RequestMapping(value = "/getJobExpectList", method = RequestMethod.GET)
//    @ApiOperation(value = "查询期望职位", notes = "查询期望职位")
//    public ResponseData getJobExpectList() {
//        int memberId = 0;
//        JobExpectParam jobExpectParam = new JobExpectParam();
//        try {
//            //取得当前Token登录者会员的ID
//            memberId = MemberTokenUtil.getMemberId();
//        } catch (Exception e) {
//            System.err.println(e.getMessage());
//        }
//        jobExpectParam.setMemberId(memberId);
//        return ResponseData.success(jobExpectService.findListBySpec(jobExpectParam));
//    }
//
//
//    /**
//     * 查询期望职位详情
//     */
//    @ResponseBody
//    @RequestMapping(value = "/getJobExpectDetail", method = RequestMethod.GET)
//    @ApiOperation(value = "查询期望职位", notes = "查询期望职位")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query")
//    })
//    public ResponseData getJobExpectDetail(Long id) {
//        return ResponseData.success(jobExpectService.getById(id));
//    }
//
//
//    /**
//     * 根据ID删除期望职位
//     */
//    @ResponseBody
//    @RequestMapping(value = "/deleteJobExpectById", method = RequestMethod.GET)
//    @ApiOperation(value = "根据ID删除期望职位", notes = "根据ID删除期望职位")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query")
//    })
//    public ResponseData deleteJobExpectById(Long id) {
//        return ResponseData.success(jobExpectService.removeById(id));
//    }
//
//
//    /**
//     * 添加/更新工作经历
//     */
//    @ResponseBody
//    @RequestMapping(value = "/updateWorkExp", method = RequestMethod.POST)
//    @ApiOperation(value = "更新期望职位", notes = "更新期望职位")
//    public ResponseData updateWorkExp(@RequestBody WorkExpParam workExpParam) {
//        //取得当前Token登录者会员的ID
//        int memberId = MemberTokenUtil.getMemberId();
//        workExpParam.setMemberId(memberId);
//        workExpService.update(workExpParam);
//        return ResponseData.success();
//    }
//
//    /**
//     * 查询工作经历列表
//     */
//    @ResponseBody
//    @RequestMapping(value = "/getWorkExpList", method = RequestMethod.GET)
//    @ApiOperation(value = "查询工作经历列表", notes = "查询工作经历列表")
//    public ResponseData getWorkExpList() {
//        //取得当前Token登录者会员的ID
//        int memberId = MemberTokenUtil.getMemberId();
//        WorkExpParam workExpParam = new WorkExpParam();
//        workExpParam.setMemberId(memberId);
//        return ResponseData.success(workExpService.findListBySpec(workExpParam));
//    }
//
//
//    /**
//     * 查询工作经历详情
//     */
//    @ResponseBody
//    @RequestMapping(value = "/getWorkExpDetail", method = RequestMethod.GET)
//    @ApiOperation(value = "查询工作经历详情", notes = "查询工作经历详情")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query")
//    })
//    public ResponseData getWorkExpDetail(Long id) {
//        return ResponseData.success(workExpService.getById(id));
//    }
//
//
//    /**
//     * 根据ID删除工作经历
//     */
//    @ResponseBody
//    @RequestMapping(value = "/deleteWorkExpById", method = RequestMethod.GET)
//    @ApiOperation(value = "根据ID删除工作经历", notes = "根据ID删除工作经历")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query")
//    })
//    public ResponseData deleteWorkExpById(Long id) {
//        return ResponseData.success(workExpService.removeById(id));
//    }
//
//
//    /**
//     * 添加/更新项目经历
//     */
//    @ResponseBody
//    @RequestMapping(value = "/updateProExp", method = RequestMethod.POST)
//    @ApiOperation(value = "添加/更新项目经历", notes = "添加/更新项目经历")
//    public ResponseData updateProExp(@RequestBody ProExpParam proExpParam) {
//        //取得当前Token登录者会员的ID
//        int memberId = MemberTokenUtil.getMemberId();
//        proExpParam.setMemberId(memberId);
//        proExpService.update(proExpParam);
//        return ResponseData.success();
//    }
//
//    /**
//     * 查询项目经历列表
//     */
//    @ResponseBody
//    @RequestMapping(value = "/getProExpList", method = RequestMethod.GET)
//    @ApiOperation(value = "查询项目经历列表", notes = "查询项目经历列表")
//    public ResponseData getProExpList() {
//        //取得当前Token登录者会员的ID
//        int memberId = MemberTokenUtil.getMemberId();
//        ProExpParam proExpParam = new ProExpParam();
//        proExpParam.setMemberId(memberId);
//        return ResponseData.success(proExpService.findListBySpec(proExpParam));
//    }
//
//
//    /**
//     * 查询项目经历详情
//     */
//    @ResponseBody
//    @RequestMapping(value = "/getProExpDetail", method = RequestMethod.GET)
//    @ApiOperation(value = "查询项目经历详情", notes = "查询项目经历详情")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query")
//    })
//    public ResponseData getProExpDetail(Long id) {
//        return ResponseData.success(proExpService.getById(id));
//    }
//
//
//    /**
//     * 根据ID删除项目经历
//     */
//    @ResponseBody
//    @RequestMapping(value = "/deleteProExpById", method = RequestMethod.GET)
//    @ApiOperation(value = "根据ID删除项目经历", notes = "根据ID删除项目经历")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query")
//    })
//    public ResponseData deleteProExpById(Long id) {
//        return ResponseData.success(proExpService.removeById(id));
//    }
//
//    /**
//     * 添加/更新教育经历
//     */
//    @ResponseBody
//    @RequestMapping(value = "/updateEduExp", method = RequestMethod.POST)
//    @ApiOperation(value = "添加/更新教育经历", notes = "添加/更新教育经历")
//    public ResponseData updateEduExp(@RequestBody EduExpParam eduExpParam) {
//        //取得当前Token登录者会员的ID
//        int memberId = MemberTokenUtil.getMemberId();
//        eduExpParam.setMemberId(memberId);
//        eduExpService.update(eduExpParam);
//        return ResponseData.success();
//    }
//
//
//    /**
//     * 查询教育经历列表
//     */
//    @ResponseBody
//    @RequestMapping(value = "/getEduExpList", method = RequestMethod.GET)
//    @ApiOperation(value = "查询教育经历列表", notes = "查询教育经历列表")
//    public ResponseData getEduExpList() {
//        //取得当前Token登录者会员的ID
//        int memberId = MemberTokenUtil.getMemberId();
//        EduExpParam eduExpParam = new EduExpParam();
//        eduExpParam.setMemberId(memberId);
//        return ResponseData.success(eduExpService.findListBySpec(eduExpParam));
//    }
//
//
//    /**
//     * 查询教育经历详情
//     */
//    @ResponseBody
//    @RequestMapping(value = "/getEduExpDetail", method = RequestMethod.GET)
//    @ApiOperation(value = "查询教育经历详情", notes = "查询教育经历详情")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query")
//    })
//    public ResponseData getEduExpDetail(Long id) {
//        return ResponseData.success(eduExpService.getById(id));
//    }
//
//    /**
//     * 根据ID删除教育经历
//     */
//    @ResponseBody
//    @RequestMapping(value = "/deleteEduExpById", method = RequestMethod.GET)
//    @ApiOperation(value = "根据ID删除教育经历", notes = "根据ID删除教育经历")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query")
//    })
//    public ResponseData deleteEduExpById(Long id) {
//        return ResponseData.success(eduExpService.removeById(id));
//    }
//
//
//    /**
//     * 查询简历附件列表
//     */
//    @ResponseBody
//    @RequestMapping(value = "/getResumeFileList", method = RequestMethod.GET)
//    @ApiOperation(value = "查询简历附件列表", notes = "查询简历附件列表")
//    public ResponseData getResumeFileList() {
//        try{
//            //取得当前Token登录者会员的ID
//            int memberId = MemberTokenUtil.getMemberId();
//            ResumeFileParam resumeFileParam = new ResumeFileParam();
//            resumeFileParam.setMemberId(memberId);
//            return ResponseData.success(resumeFileService.findListBySpec(resumeFileParam));
//        }catch (Exception e){
//            return ResponseData.success(e.getMessage());
//        }
//    }
//
//    /**
//     * 根据ID删除附件简历
//     */
//    @ResponseBody
//    @RequestMapping(value = "/deleteResumeFileById", method = RequestMethod.GET)
//    @ApiOperation(value = "根据ID删除附件简历", notes = "根据ID删除附件简历")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query")
//    })
//    public ResponseData deleteResumeFileById(Long id) {
//        return ResponseData.success(resumeFileService.removeById(id));
//    }
//
//
//    /**
//     * 导出简历模板
//     */
//    @ResponseBody
//    @RequestMapping(value = "/exportWord", method = RequestMethod.GET)
//    @ApiOperation(value = "导出简历模板", notes = "导出简历模板")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "简历ID", value = "id", required = true, paramType = "query")
//    })
//    public ResponseData exportWord(HttpServletRequest request, HttpServletResponse response, Long id) {
//        try {
//            ResumeParam resumeParam = new ResumeParam();
//            resumeParam.setId(id);
//            int memberId = MemberTokenUtil.getMemberId();
//            resumeParam.setMemberId(memberId);
//            //判断是否已超过5份简历
//            List<ResumeFileResult> list= resumeFileService.findListBySpec(new ResumeFileParam().setMemberId(memberId));
//            if (list.size()==5){
//                return ResponseData.error("不能超过5份附件简历哦");
//            }
//            // 构造freemarker模板引擎参数,listVars.size()个数对应pdf页数
//            String url = resumeFileService.exportWordFile(request, resumeParam);
//            return ResponseData.success(url);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return ResponseData.error("导出失败，请完善简历内容");
//        }
//    }
//}